package com.andy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.andy.db.CoinInfo;
import com.andy.dogcoin.R;

import java.util.List;

/**
 * Created by Andy on  2024/4/25 1:03
 * Email: 963069079@qq.com
 */
public class DetailAdapter extends RecyclerView.Adapter<DetailAdapter.DetailViewHolder> {
//    private List<String> mData;
//
//    public MyAdapter(List<String> data) {
//        mData = data;
//    }

    private List<CoinInfo> mList;
    private Context mContext;
    public DetailAdapter(List<CoinInfo> mList,Context mContext){
        this.mList=mList;
        this.mContext=mContext;
    }
    @Override
    public DetailViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_coin_detail_item, parent, false);
        return new DetailAdapter.DetailViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(DetailAdapter.DetailViewHolder holder, int position) {
//        holder.textView_nane.setText(mList.get(position).coin_name);
        holder.textView_market_value.setText("市值 : " + mList.get(position).market_value);
        holder.textView_people_number.setText("持币人数 : " + mList.get(position).people_number);
        holder.textView_price.setText("价格 : " + mList.get(position).price);
        holder.textView_trade_volume.setText("24H交易额 : " + mList.get(position).trade_volume);
        holder.textView_trade_number.setText("24H交易数字 : " + mList.get(position).trade_number);
        holder.textView_save_time.setText("保存时间 : " + mList.get(position).save_time);
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class DetailViewHolder extends RecyclerView.ViewHolder {
        public TextView textView_market_value;
        public TextView textView_people_number;
        public TextView textView_price;
        public TextView textView_trade_volume;
        public TextView textView_trade_number;
        public TextView textView_save_time;


        public DetailViewHolder(View itemView) {
            super(itemView);
            textView_market_value = itemView.findViewById(R.id.adapter_coin_detail_item_market_value);
            textView_people_number = itemView.findViewById(R.id.adapter_coin_detail_item_people_number);
            textView_price = itemView.findViewById(R.id.adapter_coin_detail_item_price);
            textView_trade_volume = itemView.findViewById(R.id.adapter_coin_detail_item_trade_volume);
            textView_trade_number = itemView.findViewById(R.id.adapter_coin_detail_item_trade_number);
            textView_save_time = itemView.findViewById(R.id.adapter_coin_detail_item_save_time);
        }
    }


}
